/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package server.entity;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author USER
 */
@Entity
@Table(name = "Category", catalog = "WebPhotoShare", schema = "dbo")
@NamedQueries({
    @NamedQuery(name = "Category.findAll", query = "SELECT c FROM Category c"),
    @NamedQuery(name = "Category.findByCollectionID", query = "SELECT c FROM Category c WHERE c.collectionID = :collectionID"),
    @NamedQuery(name = "Category.findByCollectionName", query = "SELECT c FROM Category c WHERE c.collectionName = :collectionName"),
    @NamedQuery(name = "Category.findByAdmin", query = "SELECT c FROM Category c WHERE c.admin = :admin"),
    @NamedQuery(name = "Category.findByDate", query = "SELECT c FROM Category c WHERE c.date = :date"),
    @NamedQuery(name = "Category.findByImage", query = "SELECT c FROM Category c WHERE c.image = :image")})
public class Category implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "CollectionID", nullable = false, length = 5)
    private String collectionID;
    @Basic(optional = false)
    @Column(name = "CollectionName", nullable = false, length = 20)
    private String collectionName;
    @Basic(optional = false)
    @Lob
    @Column(name = "CollectionDescription", nullable = false, length = 2147483647)
    private String collectionDescription;
    @Basic(optional = false)
    @Column(name = "Admin", nullable = false)
    private boolean admin;
    @Basic(optional = false)
    @Column(name = "Date", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date date;
    @Column(name = "Image", length = 50)
    private String image;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "category")
    private Collection<Photo> photoCollection;
    @JoinColumn(name = "RUsername", referencedColumnName = "Username")
    @ManyToOne
    private RegisteredUser registeredUser;

    public Category() {
    }

    public Category(String collectionID) {
        this.collectionID = collectionID;
    }

    public Category(String collectionID, String collectionName, String collectionDescription, boolean admin, Date date) {
        this.collectionID = collectionID;
        this.collectionName = collectionName;
        this.collectionDescription = collectionDescription;
        this.admin = admin;
        this.date = date;
    }

    public String getCollectionID() {
        return collectionID;
    }

    public void setCollectionID(String collectionID) {
        this.collectionID = collectionID;
    }

    public String getCollectionName() {
        return collectionName;
    }

    public void setCollectionName(String collectionName) {
        this.collectionName = collectionName;
    }

    public String getCollectionDescription() {
        return collectionDescription;
    }

    public void setCollectionDescription(String collectionDescription) {
        this.collectionDescription = collectionDescription;
    }

    public boolean getAdmin() {
        return admin;
    }

    public void setAdmin(boolean admin) {
        this.admin = admin;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public String getImage() {
        return image;
    }

    public void setImage(String image) {
        this.image = image;
    }

    public Collection<Photo> getPhotoCollection() {
        return photoCollection;
    }

    public void setPhotoCollection(Collection<Photo> photoCollection) {
        this.photoCollection = photoCollection;
    }

    public RegisteredUser getRegisteredUser() {
        return registeredUser;
    }

    public void setRegisteredUser(RegisteredUser registeredUser) {
        this.registeredUser = registeredUser;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (collectionID != null ? collectionID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Category)) {
            return false;
        }
        Category other = (Category) object;
        if ((this.collectionID == null && other.collectionID != null) || (this.collectionID != null && !this.collectionID.equals(other.collectionID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "server.entity.Category[collectionID=" + collectionID + "]";
    }

}
